package com.iscas.loadstorm.isloadstorm.executor;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;


@Configuration
public class TaskExecutorConfig {
    @Bean(name = "customTaskExecutor") // 改为自定义唯一名称
    public ThreadPoolTaskExecutor taskExecutor() {
        // 显式声明类型
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(10); // 核心线程数
        executor.setMaxPoolSize(50);  // 最大线程数
        executor.setQueueCapacity(100); // 队列容量
        executor.setThreadNamePrefix("JMeterExecutor-"); // 线程名称前缀
        executor.initialize(); // 初始化线程池
        return executor;
    }
}